package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.sys.entity. CarDispatchEntity;
import io.renren.modules.sys.service. CarDispatchService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-03-11 15:42:35
 */
@RestController
@RequestMapping("sys/carDispatch")
public class CarDispatchController {
    @Autowired
    private  CarDispatchService  carDispatchService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:carDispatch:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page =  carDispatchService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:carDispatch:info")
    public R info(@PathVariable("id") Long id){
			 CarDispatchEntity  carDispatch =  carDispatchService.selectById(id);

        return R.ok().put("carDispatch",  carDispatch);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys: carDispatch:save")
    public R save(@RequestBody  CarDispatchEntity  carDispatch){
			 carDispatchService.insert( carDispatch);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys: carDispatch:update")
    public R update(@RequestBody  CarDispatchEntity  carDispatch){
			 carDispatchService.updateById( carDispatch);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys: carDispatch:delete")
    public R delete(@RequestBody Long[] ids){
			 carDispatchService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
